package com.springboot.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.springboot.mapper.UserMapper;
import com.springboot.pojo.User;
import com.springboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static net.sf.jsqlparser.util.validation.metadata.NamedObject.user;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper,User> implements UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> getAllUsers() {
        Page<Object> pages = PageHelper.startPage(1, 2);
        List<User> allUsers = userMapper.getAllUsers();
        System.out.println("allUsers = " + allUsers);
        List<Object> result = pages.getResult();
        System.out.println("result = " + result);
        return allUsers;
    }

    @Override
    public List<User> select() {
        User user1 = new User();
        user1.setId(1);
        List<User> userById = userMapper.getUserById(user1);
        for (User user : userById) {
            System.out.println("user = " + user);

        }
        return userById;
    }

}
